home *** CD-ROM | disk | FTP | other *** search
/ STraTOS 1997 April & May / STraTOS 1 - 1997 April & May.iso / CD01 / INTERNET / SITES / RAND / DVIEW000.LZH / MAINMS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-30  |  4.7 KB  |  190 lines

  1. /********************************************************************
  2.  FILENAME: MAINMS.CPP
  3.  AUTHOR  : JAKE HILL
  4.  DATE    : 12/1/94
  5.  
  6.  Copyright (c) 1994 by Jake Hill:
  7.  If you use any part of this code in your own project, please credit
  8.  me in your documentation and source code.  Thanks.
  9. ********************************************************************/
  10.  
  11. #define C
  12.  
  13. #include "trig.h"
  14. #include "view.h"
  15. #include "keyboard.h"
  16.  
  17. #ifdef __GNUC__
  18. #include <osbind.h>
  19. #else
  20. #include <tos.h>
  21. #endif
  22.  
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25.  
  26. #ifdef C
  27. extern void ViewSetup(void);
  28. extern void ViewRemove(void);
  29. extern void OpenWad(char *, long);
  30. extern void Close(void);
  31. extern void DrawView(void);
  32. extern void SetView(short *, short *, short *, unsigned short *);
  33. extern void GetView(short *, short *, short *, unsigned short *);
  34. #endif
  35.  
  36. extern void get_key(short *, short *);
  37.  
  38. void main(int argc, char *argv[])
  39. {
  40.    short Px, Py, Ph;
  41.    long FrameCount = 0L;
  42.    unsigned short Pangle;
  43.    char *WadFile = "DOOM.WAD";
  44.    short Level = 0, Step = 8, Turn = 1024;
  45.    int index = 0;
  46.    short key, key_flags;
  47.  
  48.    printf("This program was originally written for the PC by Jake Hill\n");
  49.    printf("(jkhil@dbsoftware.com) and was released Decemeber 1, 1994.\n");
  50.    printf("According to Jake's wishes, the full DVIEW sources and read.me\n");
  51.    printf("file must be included with any distribution.\n\n");
  52.    printf("The conversion to the Atari Falcon and TT was done by\n");
  53.    printf("Johan Klockars (d8klojo@dtek.chalmers.se).\n");
  54.    printf("The Copyright (1994) of the Atari assembly chunky to planar\n");
  55.    printf("routine is owned by Johan Klockars, but is available on\n");
  56.    printf("request for use in other FreeWare (and similar) software.\n");
  57.    printf("-------------------------------------------------------\n");
  58.    printf("Up to two parameters can be given. The last one is the level\n");
  59.    printf("number to view, but the name of a .WAD file to load can be\n");
  60.    printf("given before that.\n\n");
  61.    printf("Move around using 8/2, 4/6, 1/3 and +/-, preferably on the\n");
  62.    printf("numeric keyboard. Quit by pressing ESC a couple of times.\n");
  63.    printf("More colours: f/w. Low memory operation F/W.\n");
  64.    printf("Single step drawing (depends on mode): s. Your position: p\n");
  65.    printf("\n");
  66.  
  67. #ifndef C
  68.    View Map;
  69. #else
  70.    ViewSetup();
  71. #endif
  72.  
  73.    if (argc == 2)
  74.       Level = atoi(argv[1]);
  75.    else if (argc == 3) {
  76.       WadFile = argv[1];
  77.       Level   = atoi(argv[2]);
  78.    }
  79. #ifndef C
  80.    Map.OpenWad(WadFile, Level);
  81. #else
  82.    OpenWad(WadFile, Level);
  83. #endif
  84.  
  85.    SetKeyboardInt();
  86.  
  87. #ifndef C
  88.    Map.GetView(&Px, &Py, &Ph, &Pangle);
  89. #else
  90.    GetView(&Px, &Py, &Ph, &Pangle);
  91. #endif
  92.  
  93.    printf("Let's get started then...\n");
  94.  
  95. #ifndef C
  96.    Map.SetView(Px,Py,Ph,Pangle);
  97.    Map.DrawView();
  98. #else
  99.    SetView(&Px, &Py, &Ph, &Pangle);
  100.    DrawView();
  101. #endif
  102.  
  103. #if 0
  104.    float T1,T2,dT;
  105.    struct _dostime_t t1,t2;
  106.    _dos_gettime(&t1);
  107. #endif
  108.  
  109.    get_key(&key, &key_flags);
  110.  
  111.    while (key != 1) {
  112.       FrameCount++;
  113.  
  114.     while (key == -1)
  115.       get_key(&key, &key_flags);
  116.  
  117.     while ((key != -1) && (key != 1)) {
  118.       if (key_flags & FLAG_UP) {
  119.          Px += xCosA( Step, Pangle );
  120.          Py += xSinA( Step, Pangle );
  121.       }
  122.       if (key_flags & FLAG_DOWN) {
  123.          Px -= xCosA(Step, Pangle);
  124.          Py -= xSinA(Step, Pangle);
  125.       }
  126.  
  127.       if ((key_flags & FLAG_SRIGHT) == FLAG_SRIGHT) {
  128.          Px += xCosA(Step, Pangle-0x4000);
  129.          Py += xSinA(Step, Pangle-0x4000);
  130.       } else if (key_flags & FLAG_RIGHT)
  131.          Pangle -= Turn;
  132.  
  133.       if ((key_flags & FLAG_SLEFT) == FLAG_SLEFT) {
  134.          Px += xCosA(Step, Pangle+0x4000);
  135.          Py += xSinA(Step, Pangle+0x4000);
  136.       } else if (key_flags & FLAG_LEFT)
  137.          Pangle += Turn;
  138.  
  139.       if (key == KEY_PLUS)
  140.          Ph += 10;
  141.  
  142.       if (key == KEY_MINUS)
  143.          Ph -= 10;
  144.  
  145.       get_key(&key, &key_flags);
  146.     }
  147. #ifndef C
  148.       Map.SetView(Px,Py,Ph,Pangle);
  149.       Map.DrawView();
  150. #else
  151.       SetView(&Px, &Py, &Ph, &Pangle);
  152.       DrawView();
  153. #endif
  154.  
  155. #if 0
  156.       printf("Frame: %ld\n", FrameCount);
  157. #endif
  158.       get_key(&key, &key_flags);
  159.    }
  160.  
  161.    printf("\n");
  162.  
  163. #if 0
  164.    _dos_gettime(&t2);
  165. #endif
  166. #ifndef C
  167.    Map.Close();
  168. #else
  169.    Close();
  170. #endif
  171.  
  172. #if 0
  173.    T1 = t1.hsecond+(t1.second*100)+(t1.minute*6000);
  174.    T2 = t2.hsecond+(t2.second*100)+(t2.minute*6000);
  175.    dT = T2 - T1;
  176.    float fps = (float) FrameCount / ( (float) dT / 100 );
  177. #endif
  178.  
  179.    ResetKeyboardInt();
  180.  
  181.    printf("\n");
  182. #if 0
  183.    printf("FPS = %f\n",fps);
  184.    printf("Elapsed Time = %4.2f\n",dT/100);
  185. #endif
  186. #ifdef C
  187.    ViewRemove();
  188. #endif
  189. }
  190.